-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(libs/form-builder): add capacity to change the default behavior 'onChange' #102
Conversation
@@ -35,7 +35,7 @@ export interface FormBuilderProps { | |||
onSubmit: SubmitHandler<FieldValues>; | |||
onNextStep?: (value: UnpackNestedValue<FieldValues>) => void; | |||
defaultValues?: DefaultValues<FieldValues>; | |||
behavior?: keyof ValidationMode; | |||
behavior?: keyof ValidationMode | 'onChangeTriggerByField'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add this new possible value in docs? 👀
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #102 +/- ##
==========================================
- Coverage 74.68% 72.65% -2.03%
==========================================
Files 28 28
Lines 391 395 +4
Branches 125 127 +2
==========================================
- Hits 292 287 -5
- Misses 64 67 +3
- Partials 35 41 +6 ☔ View full report in Codecov by Sentry. |
We got an issue in our main project: when typing the email (as the login in register form) we check on the onChange if the email is already taken or not with a backend request (via gigya).
Once this is done, we discovered that on the next field (password), each keydown was also firing the onChange event with all the validation methods assigned from all the fields.
Description
The fix made is to use the onSubmit event instead of the onChange and pass this behavior as a parameter in order not to risk breaking all our forms.
Related Issue
Can't reproduce on this repo.
Types of changes
Checklist